package com.c78.fz.controller;

import com.c78.fz.common.result.Result;
import com.c78.fz.model.entity.Client;
import com.c78.fz.service.ClientService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/clients")
public class ClientController {
    @Resource
    ClientService clientService;

    @GetMapping("/getclient")
    public Result list(String name,String phone,Integer pageNum,Integer pageSize){
        return clientService.getClientPage(name,phone,pageNum,pageSize);
    }

    @PostMapping("/addclient")
    public Result addClient(@RequestBody Client client){
        return clientService.saveClient(client);
    }

    @GetMapping("/getclientbyid/{id}")
    public Result getClientById(@PathVariable Integer id) {
        return clientService.getClientById(id);
    }

    @PutMapping("/updclient")
    public Result updateClient(@RequestBody Client client) {
        return clientService.updateClient(client);
    }

    @DeleteMapping("/delclient/{id}")
    public Result deleteClient(@PathVariable Integer id) {
        return clientService.deleteClient(id);
    }

    @GetMapping("/getclientlist")
    public Result getClientList(){
        return clientService.getClient();
    }
}
